﻿using System.ComponentModel;

namespace WXWorkSvc.Common.Data;
[EntityTypeConfiguration(typeof(TUserConfig))]
public class TUser
{
    [StringLength(32)]
    public string SuiteId { get; set; } = default!;
    [StringLength(32)]
    public string CorpId { get; set; } = default!;
    [StringLength(64)]
    [Display(Name = "用户名")]
    public string UserId { get; set; } = default!;
    [NotMapped]
    [Display(Name = "姓名")]
    public string UserName { get => @$"<ww-open-data type='userName' openid='{UserId}'></ww-open-data>"; }
    [Display(Name = "角色")]
    public int Roles { get; set; }
    [Display(Name = "角色")]
    [NotMapped]
    public string? RoleNames { get; set; }
    [NotMapped]
    [DisplayName("单位管理员")]
    public string? Admins { get; set; }
    [NotMapped]
    [DisplayName("接收")]
    public bool IsReceive { get; set; }
    [ForeignKey(nameof(SuiteId))]
    public virtual TSuite Suite { get; set; } = default!;
    [ForeignKey(nameof(CorpId))]
    public virtual TCorp Corp { get; set; } = default!;
}
public class TUserConfig : IEntityTypeConfiguration<TUser>
{
    public void Configure(EntityTypeBuilder<TUser> builder)
    {
        builder.HasKey(ii => new { ii.SuiteId, ii.CorpId, ii.UserId });
    }
}
